package br.com.management.mentor;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import br.com.management.mentor.app.exceptions.AppStartUpException;
import br.com.management.mentor.view.core.ViewManager;

public class App {

	private static final Log logger = LogFactory.getLog( App.class );

	public static final String SPRING_CONFIG_FILE = "application-context.xml";

	public static void main( String[] args ) {
		AbstractApplicationContext context = null;

		try {
			context = new ClassPathXmlApplicationContext( new String[] { SPRING_CONFIG_FILE } );
			context.registerShutdownHook();
			context.start();

			ViewManager viewManager = context.getBean( ViewManager.class );
			viewManager.start();

		} catch ( AppStartUpException asue ) {
			logger.error( "Error while starting app." , asue );
		} catch ( Exception e ) {
			logger.error( "Error" , e );
		} finally {
			if ( context != null ) {
				context.close();
			}
		}

	}

}